angular.module('prize').controller('prizeDetailCtrl', ['$scope', '$uibModalInstance', '$http', 'id', function ($scope, $uibModalInstance, $http, id) {
    $scope.prize = {
        title: '',
        description: '',
        total: 0,
        risk: 0
    };
    $scope.onInit = function () {
        if (id)
            $http.get(ctx + '/prize/detail/' + id).then(function (resp) {
                $scope.prize = resp.data;
            });
    }
    $scope.onInit();
    $scope.ok = function () {
        $http.post(ctx + '/prize/save', $scope.prize).then(function (resp) {
            $uibModalInstance.close();
        });
    };

    $scope.cancel = function () {
        $uibModalInstance.dismiss('cancel');
    };
}]);